import React from 'react';
import { useEffect, useState } from 'react';
import {Button} from 'antd';
// import Cron from "qnn-react-cron"
import QnnReactCron from "qnn-react-cron"
import styles from './index.less';

const cron: React.FC = () => {

  let cronFns: any;
  let [value, setValue] = useState();

  return (
    <div className={styles.content}>
      <div className={styles.cron}>
        <QnnReactCron
          value={value}
          onOk={(value) => {
            console.log("cron:", value);
          }}
          getCronFns={(_cronFns: any) => {
            cronFns = _cronFns;
          }}
          footer={[
            <Button
              key="cencel"
              style={{ marginRight: 10 }}
              onClick={() => {
                setValue(null);
              }}
            >
              重置
            </Button>,
            <Button
              key="getValue"
              type="primary"
              onClick={() => {
                setValue(cronFns.getValue());
              }}
            >
              生成
            </Button>
          ]}
        />
      </div>

      <div style={{ textAlign: "center", margin: "12px 0px" }}>值：{value}</div>

    </div>
  )

};

export default cron;
